<template>
	<view class="index">
		<!-- 骨架 -->
		<view class="skeleton" v-if="loading">
			<m-for-skeleton :avatarSize="200" :row="3" :loading="loading" :title="false" :titleStyle="{}"
				v-for="(item,key) in 4" :key="key">
			</m-for-skeleton>
		</view>
		<!-- 主要内容 -->
		<view class="container" v-show="!loading">
			<scroll-view scroll-y="true">
				<!-- 搜索框 -->
				<view class="index-search">
					<text class="iconfont icon-sousu"></text>
					<input type="text" placeholder="搜索歌曲" />
				</view>
				<!-- 榜单 -->
				<view class="index-list-item" v-for="(item,index) in list" :key="index" @tap="goToList(item.id)">
					<!-- 榜单图片 -->
					<view class="index-list-img">
						<image class="logo" :src="item.coverImgUrl"></image>
						<text>{{item.updateFrequency}}</text>
					</view>
					<!-- 榜单歌曲 -->
					<view class="index-list-text">
						<view v-for="(musicItem,index) in item.tracks" :key="index">
							{{index+1}}.{{musicItem.first}}-{{musicItem.second}}
						</view>
					</view>
				</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	import mForSkeleton from "../../components/m-for-skeleton/m-for-skeleton";
	import myHead from '../../components/myHead/myHead.vue'
	import {
		toplist
	} from '../../commom/api.js'
	export default {
		data() {
			return {
				list: {

				},
				title: "列表",
				loading: true
			}
		},

		components: {
			myHead,
			mForSkeleton
		},
		onLoad() {
			toplist().then(res => {
				this.list = res;
				setTimeout(() => {
					this.loading = false;
				}, 1000);
			})

		},
		methods: {
			goToList(id) {
				uni.navigateTo({
					url: '/pages/list/list?listid=' + id,
				});
			},
			hide() {
				this.loading = false;
			}

		}
	}
</script>
<style>
	.index {
		margin: 20rpx;
	}

	.container {
		display: flex;
	}

	.index-search {
		display: flex;
		align-items: center;
		height: 70rpx;
		margin: 70rpx 30rpx 30rpx 30rpx;
		background: #f7f7f7;
		border-radius: 50rpx;
	}

	.index-search .iconsearch {
		width: 40rpx;
		height: 40rpx;
	}

	.index-search text {
		font-size: 40rpx;
		margin-right: 26rpx;
		margin-left: 28rpx;
	}

	.index-search input {
		font-size: 28rpx;
		flex: 1;
	}

	.index-list {
		margin: 0 30rpx;
	}

	.index-list-item {
		display: flex;
		margin-bottom: 34rpx;
	}

	.index-list-img {
		width: 210rpx;
		height: 210rpx;
		position: relative;
		border-radius: 20rpx;
		overflow: hidden;
		margin-right: 22rpx;
		flex-shrink: 0; /* 不被其他元素影响 */
	}

	.index-list-img image {
		width: 100%;
		height: 100%;
	}

	.index-list-img text {
		position: absolute;
		left: 12rpx;
		bottom: 16rpx;
		color: #fff;
		font-size: 20rpx;
	}

	.index-list-text {
		height: 210rpx;
		color: #6f6f6f;
		font-size: 25rpx;
	}

	.index-list-text view {
		padding: 10rpx;
	}
</style>